package ua.crimea.bat.ss.model.beans;

import org.hibernate.annotations.Entity;

import javax.persistence.*;
import java.io.Serializable;

/**
 * <p/>
 * <p/>
 * Original Author:   <a href="mailto:Alexey Batyuta <alexey@pilgrimcs.com.ua>">Alexey Batyuta</a><br/>
 * Created Date:     Oct 11, 2010 <br/>
 * Created Time:     4:03:42 PM <br/>
 * <p/>
 * $Id: BaseBean.java 63 2010-11-11 15:14:21Z alexey.batyuta@gmail.com $
 * <p/>
 * $Author: alexey.batyuta@gmail.com $
 * $Date: 2010-11-11 15:14:21 +0000 (Thu, 11 Nov 2010) $
 * $Rev: 63 $
 * $URL: http://bat-test-docs.googlecode.com/svn/tags/releases/spring_security-0.0.1/core/src/main/java/ua/crimea/bat/ss/model/beans/BaseBean.java $
 */

@MappedSuperclass
public abstract class BaseBean implements Serializable {
    private Integer id;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        if (null == id) {
            return -1;
        }
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Transient
    public boolean isNew() {
        return (getId() == null || getId() <= 0);
    }
}
